import { createApp } from "vue";
import router from "@/router";
import App from "./App.vue";

// element-plus
import ElementPlus from "element-plus";
import "element-plus/theme-chalk/index.css";
import * as ElementPlusIconsVue from "@element-plus/icons-vue";
import locale from "element-plus/es/locale/lang/zh-cn";

import "./assets/style/index.scss";

import './assets/Alimama/AliSheet.css'

// 自定义按钮颜色
import "./assets/style/customButton.scss"

// 展示的公共组件插槽
import showCode from "@/components/showCode";

// 自定义svg图标组件
import "virtual:svg-icons-register";
import SvgIcon from "@/components/SvgIcon/index.vue";

// 公共的锚点组件
import aAnchor from '@/components/aAnchor'

// 注册国际化
import { i18n } from "@/lang";

// 注册图片路径函数
import { getAssetsImg } from "@/utils";

import modal from "@/utils/modal";

// TODO 对vue进行类型补充说明，不然在vue页面使用的时候会报错
declare module "@vue/runtime-core" {
  interface ComponentCustomProperties {
    getAssetsImg: Function;
    modal: Function;
  }
}

const app = createApp(App);

// 全局方法挂载
app.config.globalProperties.getAssetsImg = getAssetsImg;
app.config.globalProperties.modal = modal;

// 使用element-plus，设置默认语言及全局size
app.use(ElementPlus, {
  locale: locale,
});

// 全局注册element-plus-icons
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}

app.component("showCode", showCode);
app.component("a-anchor", aAnchor);
app.component("svg-icon", SvgIcon);

app.use(i18n);
app.use(router);
app.mount("#app");
